<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <meta name="viewport" content="width=dataice-width, initial-scale=1, shrink-to-fit=no">
    <meta name="description" content="">
    <meta name="author" content="">

    <title>游戏数据管理</title>

    <!-- Bootstrap core CSS -->
    <link th:href="@{/webjars/bootstrap/4.3.1/css/bootstrap.css}" rel="stylesheet">
    <!-- Custom styles for this template -->
    <link th:href="@{/asserts/css/dashboard.css}" rel="stylesheet">
    <!-- 通知栏样式 -->
    <link th:href="@{/asserts/css/notificationBar.css}" rel="stylesheet">
</head>

<!-- 页面加载完毕就同步通知栏，如果有新通知要及时通知用户 -->
<body onload="syncNotify()">
<!-- 引入顶部栏 -->
<div th:replace="common/bar::topbar"></div>

<div class="container-fluid">
    <div class="row">
        <!-- 引入通知栏 -->
        <div th:replace="common/bar::NotificationBar"></div>

        <!-- 引入侧边栏 -->
        <div th:replace="common/bar::#sidebar(activeUri='gamedataman')"></div>

        <main role="main" class="col-md-9 ml-sm-auto col-lg-10 pt-3 px-4">
            <h2 th:if="${session.login_usr_role != 2}">游戏数据管理 | <a class="btn btn-sm btn-success"
                                                                   onclick="return gamedataAddView()">游戏数据添加</a></h2>

            <!-- 统计信息 -->
            <h5 style="color: green"><th:block th:text="'共有' + ${gamedata_statistics.nowTotal} + '条游戏数据。'" /></h5>

            <!-- 用户数据列表 -->
            <div class="table-responsive" style="overflow:auto;">
                <table class="table table-striped table-sm" style='white-space: nowrap'>
                    <thead>
                    <tr align="center">
                        <th>操作</th>
                        <th>#</th>
                        <th>设备范围</th>
                        <th>区服范围</th>
                        <th>角色数量</th>
                        <th:block th:if="${gamedata_map != null}">
                            <th:block th:each="key : ${gamedata_map.map.keySet()}">
                                <th th:text="${gamedata_map.map.get(key).name}"></th>
                            </th:block>
                        </th:block>
                    </tr>
                    </thead>
                    <tbody>
                    <tr th:each="data : ${gamedata_pages.records}" align="center">
                        <td>
                            <a class="btn btn-sm btn-primary" href="#"
                               th:onclick="'return gamedataEditView(' + ${data.id} + ')'">编辑</a>
                            <button href="#" class="btn btn-sm btn-danger deleteBtn"
                                    th:onclick="'return gamedataRemove(' + ${data.id} + ')'">删除</button>
                        </td>
                        <td th:text="${data.id}"></td>
                        <td th:text="${data.devRange}"></td>
                        <td th:text="${data.regionServerRange}"></td>
                        <td th:text="${data.nrRole}"></td>
                        <th:block th:if="${gamedata_map != null && data.resourceDataMap != null}">
                            <th:block th:each="key : ${gamedata_map.map.keySet()}">
                                <td th:if="${gamedata_map.map.get(key).limitState == false}" th:text="${data.resourceDataMap.get(key)}"></td>
                                <td th:if="${gamedata_map.map.get(key).limitState == true}" th:text="${gamedata_map.map.get(key).limit.get(data.resourceDataMap.get(key))}"></td>
                            </th:block>
                        </th:block>
                    </tr>
                    </tbody>
                </table>
            </div>
            <div>
                <!-- 查询限制 -->
                <table align="left" width="27%">
                    <tr>
                        <td>
                            <select class="form-control" onchange="return gameNameSearch()" th:name="gameName" id="game_name_select">
                                <option th:selected="${search_gamedata != null} ? ${search_gamedata.gameName == game_name}"
                                        th:value="${game_name}" th:each="game_name : ${search_game_name_list}" th:text="${game_name}">
                                </option>
                            </select>
                        </td>
                    </tr>
                </table>
                <!-- 分页控制区域 -->
                <table align="right" width="73%">
                    <tr th:if="${gamedata_pages.pages == 0}">
                        <td align="center">
                            [没有数据]
                        </td>
                    </tr>
                    <tr th:if="${gamedata_pages.pages > 0}">
                        <!-- 选择一页能显示多少 -->
                        <td align="center">
                            请选择分页大小[默认10/最大500]
                            <input type="text" name="page_size"
                                   oninput="value=value.replace(/[^\d]/g,'')" th:value="${gamedata_pages.size}" size="3">
                            <button th:onclick="'showPage(1, ' +  ${gamedata_pages.pages} + ')'">立即生效</button>
                        </td>
                        <td align="center">
                            <th:block th:text="'第' + ${gamedata_pages.current} + '/' + ${gamedata_pages.pages} + '页'"></th:block>
                        </td>
                        <th:block th:if="${gamedata_pages.current > 1}">
                            </td>
                            <td align="center">
                                <a href="javascript:void(0)" th:onclick="'showPage(1' + ', ' +  ${gamedata_pages.pages} + ')'">[首页]</a>
                            </td>
                            <td align="center">
                                <a href="javascript:void(0)" th:onclick="'showPage(' + ${gamedata_pages.current - 1} + ', ' +  ${gamedata_pages.pages} + ')'">[上一页]</a>
                            </td>
                        </th:block>

                        <td align="center">
                            <!-- 动态显示条 -->
                            <th:block th:each="i : ${#numbers.sequence(gamedata_pages.dynamicStart, gamedata_pages.dynamicEnd)}">
                                <th:block th:if="${i == gamedata_pages.current}" th:text="'[' + ${i} + ']'"></th:block>
                                <a th:if="${i != gamedata_pages.current}" href="javascript:void(0)" th:onclick="'showPage(' + ${i} + ', ' +  ${gamedata_pages.pages} + ')'">
                                    [<th:block th:text="${i}"></th:block>]
                                </a>
                            </th:block>
                        </td>

                        <th:block th:if="${gamedata_pages.current < gamedata_pages.pages}">
                            <td align="center">
                                <a href="javascript:void(0)" th:onclick="'showPage(' + ${gamedata_pages.current + 1} + ', ' +  ${gamedata_pages.pages} + ')'">[下一页]</a>
                            </td>
                            <td align="center">
                                <a href="javascript:void(0)" th:onclick="'showPage(' + ${gamedata_pages.pages} + ', ' +  ${gamedata_pages.pages} + ')'">[尾页]</a>
                            </td>
                        </th:block>
                    </tr>
                </table>
                <br>
                <br>
                <br>
            </div>
        </main>
    </div>
</div>

<!-- 引入公共的js  -->
<div th:replace="common/js::js"></div>
<!-- 自定义的js -->
<script type="text/javascript" th:src="@{/asserts/js/common.js}" ></script>
<script type="text/javascript" th:src="@{/asserts/js/gamedata.js}" ></script>

</body>
</html>